<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../js/vue.js"></script>
  <style>
    .dv {
      width: 300px;
      height: 200px;
      border: 1px solid black;
    }

    .dv1 {
      background-color: yellow;
    }

    .dv2 {
      background-color: hotpink;
    }

    .dv3 {
      background-color: teal;
    }
  </style>
</head>

<body>
  <div id="app">
    <input type="text" v-model="ips" @input="inputs">
    <div :class="[dv,dv1]">

    </div>
  </div>
</body>
<script>
  const vm = new Vue({
    el: "#app",
    data: {
      ips: 1,
      dv: "dv",
      dv1: "dv1"
    },
    methods: {
      inputs() {
        console.log(`好的了`);
        switch (this.ips) {
          case "1":
            return this.dv1 = "dv1";
            break;
          case "2":
            return this.dv1 = "dv2";
            break;
          case "3":
            return this.dv1 = "dv3";
            break;
          default:
            console.log(`输出了默认值了吧...`);
        }
        /* break; default: 可以省略的 */
      }
    }
  });
</script>

</html>